import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/10 21:17
 * @description 双重循环，暴力求解， 第二种就是哈希表
 */
public class Solution {
    public static void main(String[] args) {

    }
    public static int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new java.util.HashMap<>();
        int[] result = new int[2];
        for (int i = 0; i < nums.length; i++) {
            int temp = target - nums[i];
            if (map.containsKey(temp)) {
                result[1] = i;
                result[0] = map.get(temp);
            }
            map.put(nums[i], i);
        }
        return result;
    }
}
